package com.hyt.it.ogt.ks.feign.hystrix;

import org.apache.tomcat.jni.FileInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import com.hyt.core.exception.NestedBusinessException;
import com.hyt.it.ogt.ks.feign.FileClient;

/**
 * 文件服务Feign客户端熔断器
 */
@Component
public class FileClientHystrix implements FileClient {
    private Logger logger = LoggerFactory.getLogger(FileClientHystrix.class);
    @Override
    public String uploadFile(@RequestParam MultipartFile file) throws NestedBusinessException {
        logger.error("#上传文件失败，进入熔断");
        throw new NestedBusinessException("上传文件失败");
    }

    @Override
    public String uploadFile(@RequestBody byte[] bytes, @RequestParam String format) throws NestedBusinessException {
        logger.error("#上传byte[]文件失败，进入熔断");
        throw new NestedBusinessException("上传byte[]文件失败");
    }

    @Override
    public String uploadFile(@RequestParam(value = "content") String content, @RequestParam(value = "fileExtension") String fileExtension) throws NestedBusinessException {
        logger.error("#上传字符文件失败，进入熔断");
        throw new NestedBusinessException("上传字符文件失败");
    }



    @Override
    public String uploadImageAndCrtThumbImage(@RequestPart(value = "file") MultipartFile file) throws NestedBusinessException {
        logger.error("#上传图片并生成缩略图失败，进入熔断");
        throw new NestedBusinessException("上传图片并生成缩略图失败");
    }

    @Override
    public String getThumbImagePath(@RequestParam(value = "filePath") String filePath) throws NestedBusinessException {
        logger.error("#根据图片路径获取缩略图路径失败，进入熔断");
        throw new NestedBusinessException("根据图片路径获取缩略图路径失败");
    }

    @Override
    public FileInfo queryFileInfo(@RequestParam(value = "filePath") String filePath) throws NestedBusinessException {
        logger.error("#获取文件信息失败，进入熔断");
        throw new NestedBusinessException("获取文件信息失败");
    }

    @Override
    public byte[] downFile(@RequestParam(value = "filePath") String filePath) throws NestedBusinessException {
        logger.error("#下载文件失败，进入熔断");
        throw new NestedBusinessException("下载文件失败");
    }

    @Override
    public void deleteFile(@RequestParam(value = "filePath") String filePath) throws NestedBusinessException {
        logger.error("#删除文件失败，进入熔断");
        throw new NestedBusinessException("删除文件失败");
    }
}
